package com.example.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.Discharge;

@Repository()
public interface Discharge_Mapper extends BaseMapper<Discharge>{
	@Select("select discharge.*,patient.name patient_name "
			+ " from discharge inner join patient on discharge.patient_id=patient.id   ${where} ${limitstr}")
	public List<Discharge> select(SearchInfo info);
	@Select("select count(1) from discharge inner join patient on discharge.patient_id=patient.id   ${where} ")
	public long selectCount(SearchInfo info);
	
	@Insert("insert into discharge (patient_id,discharge_date,discharge_reason,transferinfo) values(#{patient_id},#{discharge_date},#{discharge_reason},#{transferinfo})")
	public void insert (Discharge u);
	
	@Update("update discharge set patient_id=#{patient_id},discharge_date=#{discharge_date},discharge_reason=#{discharge_reason},transferinfo=#{transferinfo} where id=#{id}")
	public void update (Discharge u);
	
	@Select("delete from discharge where id=#{id}")
	public void delete(int id);
	
	@Select("select * from discharge where id=#{id} ")
	public Discharge selectById(int id);
	
}
